﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SedionFormDesigner.Infrastructure
{
    public class ReferenceEventClosure
    {
        private Object reference;
        private EventPropertyDescriptor propertyDescriptor;

        public ReferenceEventClosure(Object reference, EventPropertyDescriptor prop)
        {
            this.reference = reference;
            this.propertyDescriptor = prop;
        }

        public override int GetHashCode()
        {
            return reference.GetHashCode() * propertyDescriptor.GetHashCode();
        }

        public override bool Equals(object otherClosure)
        {
            if (otherClosure is ReferenceEventClosure)
            {
                ReferenceEventClosure typedClosure = (ReferenceEventClosure)otherClosure;
                return (typedClosure.reference == reference &&
                    typedClosure.propertyDescriptor == propertyDescriptor);
            }
            return false;
        }
    }
}
